/**
 * 
 */
package com.dovgopoly.carlogbook.web.board.client.presenter;

import com.dovgopoly.carlogbook.common.mvp.AbstractPresenter;
import com.dovgopoly.carlogbook.services.GreetingServiceAsync;
import com.dovgopoly.carlogbook.web.board.client.ApplicationEventBus;
import com.dovgopoly.carlogbook.web.board.client.view.RootView;
import com.dovgopoly.carlogbook.web.board.client.view.RootViewImpl;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.inject.Inject;
import com.mvp4g.client.annotation.EventHandler;
import com.mvp4g.client.annotation.Presenter;

/**
 * @author Zhenya
 * 
 */
@Presenter(view = RootViewImpl.class)
public class RootPresenter extends AbstractPresenter<RootView, RootView.Presenter, ApplicationEventBus> implements
		RootView.Presenter {

	@Inject
	GreetingServiceAsync greetingService;

	@Override
	protected RootView.Presenter getPresenter() {
		return this;
	}

	@EventHandler(name = "start")
	public void onStart() {
		//
	}

	public void callServer() {
		greetingService.greetServer("fucking name", new AsyncCallback<String>() {

			public void onSuccess(String arg0) {
				Window.alert("Success " + arg0);

			}

			public void onFailure(Throwable arg0) {
				GWT.log(arg0.getMessage(), arg0);
				view.showErrorMessage("Error" + arg0.getMessage());

			}
		});

	}
}
